Page({
  data: {

  name:'',
  staffid:'',
  lst:{


  },
  qty:0,
  },

  onLoad() {


var that=this;

  dd.getStorage({
  key: 'staffid',
  success: function(res) 
  { 
    //console.log(res.data);
  that.setData({

   staffid:res.data

  });
  dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Approve/WaitMeApproveList?staffid='+res.data,
          success: function (res) {
         
         // console.log(that.data.staffid);
      
        if(res.data.msg="数据返回成功")
        {
             that.setData({
             lst:res.data.data,
            
          });

        }else{

         dd.showToast({

            content:res.data.msg,

         });

        }
        


          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束
  },
  fail: function(res){
    dd.alert({content: res.errorMessage});
  }
});

  dd.getStorage({
  key: 'name',
  success: function(res) {
   // console.log(res.data);
  that.setData({
   name:res.data

  });
  },
  fail: function(res){
    dd.alert({content: res.errorMessage});
  }
});




  },Approve:function(e)
  {
   console.log("Approved");
   console.log(e);
   var  id =e.target.dataset.value;
   console.log(id);
   dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Approve/Approved?id='+id,
          success: function (res) {
         
         // console.log(that.data.staffid);
            dd.navigateBack({
      delta: 1
     });

          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束
  },
 


  
  Reject:function(e)
  {
   console.log("Reject");
    console.log(e);
    var  id =e.target.dataset.value;
    dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Approve/Reject?id='+id,
          success: function (res) {
         
         // console.log(that.data.staffid);
        
     dd.navigateBack({
      delta: 1
     });
          console.log(res.data);
      
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束

  },
  lot:function()
  {
     //var that=this;
     var id=this.data.staffid;
    console.log(id);

      dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Approve/lot?id='+id,
          success: function (res) {
         
         // console.log(that.data.staffid);
        
      dd.showToast({
           content:res.data.msg,       
 
          });


     dd.navigateBack({
      delta: 1
     });
          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束

  },
  arrangecar:function(e)
  {
        console.log("Approved");
       console.log(e);
   var  id =e.target.dataset.value;

     dd.navigateTo({ url:'../CarArrange/CarArrange?id='+id });

  },


  
  overtimeapprove:function()
  {

    dd.navigateTo({ url:'../OvertimeApprove/OvertimeApprove' });

  }
    

  
});
